def fib(n, table=None):
    if not table:
        table = {0: 0, 1: 1}
    if n in table.keys():
        return table[n]
    else:
        table[n] = fib(n - 1) + fib(n - 2)
        return table


print(fib(6))  # 8
